/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.cezary.butler.walili.client.mime;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author czarek
 */
public class BasicFileNamingStrategy extends BaseFileNamingStrategy {

    private static final Logger log = Logger.getLogger(BasicFileNamingStrategy.class.getName());

    public BasicFileNamingStrategy(File baseDir) {
        super(baseDir);
    }

    @Override
    public String generateName(URL url) {
        try {
            return url.getHost().concat(URLDecoder.decode(url.getPath(), "UTF-8"));
        } catch (UnsupportedEncodingException ex) {
            log.log(Level.SEVERE, null, ex);
            throw new RuntimeException(ex);
        }
    }
}
